package com.demo.controller;



import com.demo.bean.User;
import com.demo.common.Result;
import com.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    UserService service;

    @RequestMapping("/saveItem")
    @ResponseBody
    public Result saveItem(User user){
        System.out.println(user);
        return service.saveItem(user);

    }

    @RequestMapping("/getAll")
    @ResponseBody
    public Result getAll(){
        List<Map> data= service.getAll();
        return Result.ok().Data(data);
    }

    @RequestMapping("/deleteUser")
    @ResponseBody
    public Result deleteUser(@RequestParam("id")String id){
        service.deleteById(id);
        return Result.ok().msg("删除用户成功");
    }
}
